/**
 *
 * @description: 首页
 * @author: junyong.hong
 * @createTime: 2019/2/21
 * @version: 1.0.0.0
 * @history:
 *    1、
 *    2、
 *
 */
const mongoose = require('mongoose')
const Category = mongoose.model('Category')


exports.homePage = async (ctx, next) => {
    const categories = await Category.find({}).populate({
        path: 'movies',
        // 挑选展示字段
        select: '_id title poster',
        // 最多筛选出8条数据
        options: { limit: 8 }
    })

    await ctx.render('pages/index' , {
        title: '首页',
        categories
    })
}